Conditions | 10 |
Paths | 6 |
Total Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
Complex classes like Renderer.any often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
1 | var DefaultHandlers = [ |
||
14 | any: function (value, expanded) { |
||
15 | var type = typeof value |
||
16 | switch (type) { |
||
17 | case 'function': |
||
18 | return value.name ? '<Function: ' + value.name + '>' : '<Function>' |
||
19 | case 'undefined': |
||
20 | return '<undefined>' |
||
21 | case 'number': |
||
22 | case 'boolean': |
||
23 | case 'string': |
||
24 | case 'symbol': |
||
25 | return value |
||
26 | default: |
||
27 | // explicitly doing nothing |
||
28 | } |
||
29 | return value instanceof Error ? Renderer.error(value, expanded) : Renderer.object(value, expanded) |
||
30 | }, |
||
31 | /** |
||
64 |